# -*- coding: utf-8 -*-
"""
@Time : 2024/2/26 3:52 PM
@Author: imamhusan
@Des: 描述
"""

from typing import List


def res_antd(data: List = None, total: int = 0, code: bool = True):
    """
    支持ant-design-table 返回的格式
    :param code:
    :param data:
    :param total:
    :return:
    """
    if data is None:
        data = []
    result = {
        "success": code,
        "data": data,
        "total": total
    }
    return result


def success(data=None, msg='', code=200):
    """
    返回成功
    :param data:
    :param msg:
    :param code:
    :return:
    """
    if data is None:
        data = []

    result = {
        'data': data,
        'message': msg,
        'code': code
    }
    return result


def fail(data=None, msg='', code=-1):
    """
    返回失败
    :param data:
    :param msg:
    :param code:
    :return:
    """
    if data is None:
        data = []

    result = {
        'data': data,
        'message': msg,
        'code': code
    }
    return result
